import {
	defineStore
} from 'pinia'

export const userStore = defineStore('user', {
    unistorage: true, // 是否持久化到内存
    state: () => {
      return {
        // 测试
        address:JSON.parse(uni.getStorageSync('address') || '{}') 
      }
    },
    actions: {
      upDateAdress(address){
        this.address = address
        this.setAdressToStorage()
      },
      setAdressToStorage(){
        uni.setStorageSync('address',JSON.stringify(this.address))
      }
    },
    getters:{
      addressStr(){
        if(!this.address.provinceName) return ''
        return this.address.provinceName + this.address.cityName + this.address.countyName + this.address.detailInfo
      }
    }
})